package com.dodalizer.parser.modifierset;

public class ModifierSet {

    /* Definitions of the bits in the modifiers field. */
    public static final int PUBLIC = 0x0001;
    public static final int PROTECTED = 0x0002;
    public static final int PRIVATE = 0x0004;
    public static final int ABSTRACT = 0x0008;
    public static final int STATIC = 0x0010;
    public static final int FINAL = 0x0020;
    public static final int SYNCHRONIZED = 0x0040;
    public static final int NATIVE = 0x0080;
    public static final int TRANSIENT = 0x0100;
    public static final int VOLATILE = 0x0200;
    public static final int STRICTFP = 0x1000;

    private int modifiers;

    public ModifierSet() {
        this.modifiers = 0;
    }

    public boolean isPublic() {
        return (modifiers & PUBLIC) != 0;
    }

    public boolean isProtected() {
        return (modifiers & PROTECTED) != 0;
    }

    public boolean isPrivate() {
        return (modifiers & PRIVATE) != 0;
    }

    public boolean isStatic() {
        return (modifiers & STATIC) != 0;
    }

    public boolean isAbstract() {
        return (modifiers & ABSTRACT) != 0;
    }

    public boolean isFinal() {
        return (modifiers & FINAL) != 0;
    }

    public boolean isNative() {
        return (modifiers & NATIVE) != 0;
    }

    public boolean isStrictfp() {
        return (modifiers & STRICTFP) != 0;
    }

    public boolean isSynchronized() {
        return (modifiers & SYNCHRONIZED) != 0;
    }

    public boolean isTransient() {
        return (modifiers & TRANSIENT) != 0;
    }

    public boolean isVolatile() {
        return (modifiers & VOLATILE) != 0;
    }

    public int removeModifier(int mod) {
        return modifiers & ~mod;
    }

    public void addModifier(int mod) {
        modifiers |= mod;
    }
}
